package com.itheima.homework;

import java.util.Scanner;

public class Test09 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入多少月");
        //键盘录入月份
        int n = sc.nextInt();
        //定义一个变量 获取调用方法后的返回值
        int r = rabbit(n);
        System.out.println(n + "个月后,兔子一共有" + r + "只");
    }

    //返回值类型为int 参数类型为int 方法名为rabbit
    public static int rabbit(int n) {
        if (n == 1) {
            return 1;
        }
        int[] arr = new int[n];
        arr[0] = 1;
        arr[1] = 1;
        for (int i = 2; i < n; i++) {
            arr[i] = arr[i - 1] + arr[i - 2];
        }
        return arr[n - 1];
    }
}
